package com.spider.test03.demo3;
//尝试编写一个矩形类，将长与宽作为矩形类的属性，在构造方法中将长，宽初始化，定义成员方法求此矩形的周长与面积
public class Square {
    private int length;
    private int width;
    public Square(){
    }
    public Square(int length, int width) {
        this.length = length;
        this.width = width;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }
    public void getPerimeter(){
        int perimeter = 2 * (length + width);
        System.out.println("周长为：" + perimeter);
    }
    public void getArea(){
        int area = length * width;
        System.out.println("面积为：" + area);
    }
}
